<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>transform</title>
</head>
<style>
    .box{
        width:100px;height:100px;margin:20px auto;background-color:#75C934;
        text-align:center;line-height:100px;font-size:18px;
        /*过渡效果*/
        -webkit-transition: transform 0.8s;
    }
    .box.active{
        /*旋转80°*/
        transform:rotate(80deg);
    }
</style>
<body>
<div class="box" onclick="transform(this)"></div>
</body>
<script>
    function transform(obj){
        obj.className=obj.className.indexOf("active")==-1?"box active":"box";
    }
</script>
</html>